package com.yiya.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yiya.bean.Renew;
import com.yiya.bean.SysUser;
import com.yiya.mapper.RenewMapper;
import com.yiya.model.RenewCplex;
import com.yiya.model.RenewCplexModel;

@Service("renewService")
public class RenewService {
	@Autowired
	private RenewMapper renewMapper;
	
	public List<RenewCplex> queryByList(RenewCplexModel bean) {
		Integer rowCount = queryByCount(bean);
		bean.getPager().setRowCount(rowCount);
		List<RenewCplex> list = renewMapper.selectByModel(bean);
		return list;
	}

	public int queryByCount(RenewCplexModel bean) {
		return renewMapper.countByModel(bean);
	}
	
	public int add(Renew bean){
		return renewMapper.insert(bean);
	}
	
	public int Update(Renew bean){
		return renewMapper.updateByPrimaryKeySelective(bean);
	}
	
	public Renew queryById(Integer id){
		return renewMapper.selectByPrimaryKey(id);
	}
	
	public void delete(Integer[] ids,SysUser user){
		for(Integer id:ids){
			Date nowTime = new Date();
			Renew bean = renewMapper.selectByPrimaryKey(id);
			bean.setUpdateBy(user.getId());
			bean.setUpdateTime(nowTime);
			bean.setDelFlag(1);
			renewMapper.updateByPrimaryKeySelective(bean);
		}
	}

}
